package main

import (
	"fmt"
	"higame/config"
	"higame/modules/log"
	"higame/modules/task"
	"higame/routes"
	"os"
	"strconv"
)

const Port = 2000

func init() {
}
func main() {
	if len(os.Args) == 1 {
		engine := routes.Setup()
		// 启动服务
		if err := engine.Run(":" + strconv.Itoa(Port)); err == nil {
			log.Info.Printf("Listening and serving HTTP on :%v", Port)
		}
	} else {
		switch os.Args[1] {
		case "-H":
			showHelp()
		case "-V":
			showVersion()
		case "-R":
			task.DbInit()
			break
		case "-D":
			task.Deploy()
			break
		default:
			log.Error.Println("命令行参数出错")
			showHelp()
			break
		}
	}
}

func showHelp() {
	fmt.Printf(`
	 _   _ _  ____                      
	| | | (_)/ ___| __ _ _ __ ___   ___ 
	| |_| | | |  _ / _%s | '_ %s _ \ / _ \
	|  _  | | |_| | (_| | | | | | |  __/
	|_| |_|_|\____|\__,_|_| |_| |_|\___|

*************【命令行帮助-参数列表】*************

-V	查看当前版本
-R	重置管理员账户密码
-H	查看帮助
-D	部署服务器

**********************************************
`, "`", "`")
}

func showVersion() {
	fmt.Println(config.Version)
}
